package com.party.mobile.task;

import com.party.common.utils.DateUtils;
import com.party.mobile.biz.analysis.StatisticalEventFlowBizService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.ParseException;
import java.util.Date;

/**
 * 事件流程统计的定时任务
 *
 * @author yuguangqing
 * @date 2018/9/12 0011
 * @time 下午 10:20
 */

@SuppressWarnings("all")
@Component(value = "quartzForEventFlow")
public class QuartzForEventFlow {

    @Autowired
    private StatisticalEventFlowBizService statisticalEventFlowBizService;

    private Logger logger = LoggerFactory.getLogger(getClass());

    /**
     * 每天凌晨1点运行脚本统计前一天事件流程的汇总数据
     */
    @Scheduled(cron = "0 0 1 * * ?")
    public void analysisEventFlow() throws ParseException {
        logger.info("事件流程统计分析开始 《《《《《《《《《《《《《");
//        Date queryDate = DateUtils.parse("2018-08-21", "yyyy-MM-dd");
        Date queryDate = DateUtils.yesterday();
        String date = DateUtils.formatDate(queryDate);
        statisticalEventFlowBizService.analysWebEvent(queryDate, date);
        statisticalEventFlowBizService.analysMobileEvent(queryDate, date);
        logger.info("事件流程统计分析结束 《《《《《《《《《《《《《");
    }
}
